package com.mzy;

import java.util.BitSet;

public class Code01_BitMap {

    public static class BitMap {
        private final long[] bits;

        public BitMap(int max) {
            bits = new long[(max + 64) >>> 6];
        }

        public void add(int num) {
            bits[num >>> 6] = bits[num >>> 6] | (1L << (num & 63));
        }

        public void delete(int num) {
            bits[num >>> 6] = bits[num >>> 6] & ~(1L << (num & 63));
        }

        public boolean contain(int num) {
            return (bits[num >>> 6] & (1L << (num % 64))) != 0;
        }
    }


    public static void main(String[] args) {
        BitMap bitMap = new BitMap(100);
        bitMap.add(10);

        BitSet bitSet = new BitSet(100);
        bitSet.set(10);
        System.out.println(bitSet.get(100));
    }
}
